package com.example.a22310.myapplication.Beans;


import android.content.Intent;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.example.a22310.myapplication.Activity.ClubDetail;
import com.squareup.picasso.Picasso;

import java.io.Serializable;
import java.util.List;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class Comment {

    /**
     * code : 200
     * comList : [{"commentid":1,"userid":1,"com_pid":2,"post_id":1,"username":"张三","pic":"2.png","content":"不错","date":"2017-08-19","flag":1}]
     */

    private int code;
    private List<ComListBean> comList;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<ComListBean> getComList() {
        return comList;
    }

    public void setComList(List<ComListBean> comList) {
        this.comList = comList;
    }

    public static class ComListBean extends BaseObservable implements Serializable {
        /**
         * commentid : 1
         * userid : 1
         * com_pid : 2
         * post_id : 1
         * username : 张三
         * pic : 2.png
         * content : 不错
         * date : 2017-08-19
         * flag : 1
         */

        private int commentid;
        private int userid;
        private int com_pid;
        private int post_id;
        private String username;
        private String pic;
        private String content;
        private String date;
        private int flag;


        public ComListBean() {
        }

        public ComListBean(int commentid, int userid, int com_pid, int post_id,String username,
                           String pic,String content,String date,int flag) {
            this.commentid = commentid;
            this.userid = userid;
            this.com_pid=com_pid;
            this.post_id =post_id;
            this.username = username;
            this.pic = pic;
            this.content=content;
            this.date=date;
            this.flag=flag;
        }
        @BindingAdapter("pic")
        public static void loadInternetImage(ImageView iv, String pic) {
            pic = IMG_URL+pic;
            Picasso.with(iv.getContext()).load(pic).into(iv);
        }

        @Override
        public String toString() {
            return "ComListBean{" +
                    "commentid='" + commentid + '\'' +
                    ", userid='" + userid + '\'' +
                    ", com_pid='" + com_pid + '\'' +
                    "post_id='" + post_id + '\'' +
                    ", username='" + username + '\'' +
                    ", pic='" + pic + '\'' +
                    "content='" + content + '\'' +
                    ", pic='" + date + '\'' +
                    "content='" + flag + '\'' +
                    '}';
        }

        public void onItemClick(View view){
            Intent intent=new Intent(view.getContext(),ClubDetail.class);
            //往详情传递数据
//            Club.ClublistBean clublistBean = new Club.ClublistBean();
//            clublistBean.setId(getId());
//            clublistBean.setClubname(getClubname());
//            clublistBean.setClubaddr(getClubaddr());
//            clublistBean.setClubpic(getClubpic());
//            clublistBean.setClubtele(getClubtele());
//            clublistBean.setClubtime(getClubtime());
//            clublistBean.setClubbrief(getClubbrief());
//            intent.putExtra("club",clublistBean);
            view.getContext().startActivity(intent);
        }

        @Bindable
        public int getCommentid() {
            return commentid;
        }

        public void setCommentid(int commentid) {
            this.commentid = commentid;
        }

        public int getUserid() {
            return userid;
        }

        public void setUserid(int userid) {
            this.userid = userid;
        }

        public int getCom_pid() {
            return com_pid;
        }

        public void setCom_pid(int com_pid) {
            this.com_pid = com_pid;
        }

        public int getPost_id() {
            return post_id;
        }

        public void setPost_id(int post_id) {
            this.post_id = post_id;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPic() {
            return IMG_URL+pic;
        }

        public void setPic(String pic) {
            this.pic = pic;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getDate() {
            return date;
        }

        public void setDate(String date) {
            this.date = date;
        }

        public int getFlag() {
            return flag;
        }

        public void setFlag(int flag) {
            this.flag = flag;
        }
    }
}
